import 'dart:convert';

import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
import 'package:schedule_self_client/common/serializers.dart';

part 'simple_resp.g.dart';

abstract class SimpleResp implements Built<SimpleResp, SimpleRespBuilder> {
  SimpleResp._();

  factory SimpleResp([void Function(SimpleRespBuilder) updates]) = _$SimpleResp;

  bool get success;

  String? get errCode;

  String? get errMessage;

  String toJson() {
    return jsonEncode(serializers.serializeWith(SimpleResp.serializer, this));
  }

  static SimpleResp? fromJson(String jsonString) {
    return serializers.deserializeWith(
        SimpleResp.serializer, jsonDecode(jsonString));
  }

  static Serializer<SimpleResp> get serializer => _$simpleRespSerializer;
}
